package com.edu.controller;

import com.edu.entity.CommonResult;
import com.edu.entity.Good;
import org.springframework.web.bind.annotation.*;

import javax.xml.transform.Result;

@RestController
@RequestMapping("/good")
public class GoodController {
    @GetMapping("/getGoodById/{goodId}")
    public CommonResult<Good> getGoodById(@PathVariable("goodId") Integer goodId) {
        //模拟返回业务数据
        return new CommonResult(200, "success", new Good(goodId, "汉堡"));
    }

    @PostMapping("/addGood")
    public CommonResult<Good> addGood(@RequestBody Good good) {
        return new CommonResult(200, "添加商品成功", new Good(good.getGoodId(), good.getGoodName()));
    }

    @PutMapping("/updateGood")
    public CommonResult<Good> updateGood(@RequestBody Good good) {
        return new CommonResult(200, "修改商品成功", new Good(good.getGoodId(), good.getGoodName()));
    }

    @DeleteMapping("/deleteGoodById/{goodId}")
    public CommonResult<Good> deleteGoodById(@PathVariable("goodId") Integer goodId) {
        return new CommonResult(200, "删除商品成功", new Good(goodId, "可乐"));
    }
}


